<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
	<div id="moduleHtml">
	  <div ><input id="loginNameInput" value="admin"/></div>
	  <div ><input id="loginPwdInput" value="cd" type="password"/></div>
	  <div ><a id="loginSubmit" >进入</a></div>
	  <div ><a id="shareAccount" >使用伙伴口令</a></div>
	</div>
</body>
  <script>
  //cofit_module_js
    Cofit.moduleSourceCode.login=function(dom){
      var module = {
        dom : $(dom) ,          
        
        show : function(){
          var dom=$(this.dom);
          
          $("body").append(dom);
          dom.dialog({
              title: 'Coffee Desk',    
              width: 400,    
              height: 200,    
              closed: false,    
              cache: false,    
              modal: true,
              closable : false
          });

          dom.find("#loginSubmit").linkbutton({    
          }); 
          dom.find("#loginSubmit").click(function(){
        	  module.onLogin();
          });
          dom.find("#shareAccount").linkbutton();
          dom.find("#shareAccount").click(function(){
        	  $.messager.prompt("伙伴口令","请输入伙伴口令",function(input){
        		  if(null!=input){
        			  $.get("./share_account/get_share_file_id/"+input,{},function(resp){
        				  if(resp.sucess){
                    Cofit.load("file_panel",function(module){
                        module.show(resp.file);
                      });        					  
        				  }else{
        					  $.messager.alert("伙伴口令",resp.msg,"error");
        				  }
        			  },"json");
        		  }
        	  });
          });
          
          dom.fadeOut(0);
          dom.fadeIn("slow","linear");
        },

        onLogin : function(){
        	
        	
        	$.get("./dict/login",{
        		username : $("#loginNameInput").val(),
        		pwd : $("#loginPwdInput").val(),
        	},function(resp){
        		if(!resp.success){
        			$.messager.alert("登录失败",resp.msg);
        		}else{
        	//TODO 登录之后
        	dom.fadeOut("slow","linear",function(){
        		dom.dialog("close");
	     	   Cofit.load("title_bar",function(module){
	     		      module.show();
	     		    });
        	});
        		}
        	},"json");
        	
        	
        }
      
      };
      return module;
    };
  //cofit_module_js
  </script>
</html>